<template>
    <div>
            <h1>
                组件B,{{ num  }}
            </h1>
            <n-button @click="count.minus(2)">--</n-button>
            <div v-for="item in star.filterList" :key="item.id">
      姓名:{{item.name}} 年龄:{{item.age}}
    </div>
    <n-button @click="handAdd">加商品</n-button>
    </div>
</template>

<script setup>
import { useCount } from '../../store/count';
import {storeToRefs} from 'pinia'
import { useStar } from '../../store/star';
import { useGood } from '../../store/good'

let count = useCount();
// let {num}=count;//对于状态机数据结果,导致丢失响应性
let {num}=storeToRefs(count);//对于状态机数据结果,不会丢失响应性
const star = useStar()
const goods = useGood()
const handAdd = ()=>{
  goods.goodsPost({
    name:'商品11',
    price:math.random()*100
})
}
</script>

<style lang="scss" scoped>

</style>